﻿/*
 * Twipler - Twitter Web Client with features.
 *  
 *  Copyright (C) 2009, 2010. Ian Quigley
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details. 
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using NHibernate.Criterion;
using Twipler.Data.Entity.Theme;

namespace Twipler.Data.Access
{
    public class DaoDesign : AbstractDaoDataEntity<Data.Entity.Theme.Design, int>
    {    
        public Data.Entity.Theme.Design Default
        {
            get
            {
                return GetById(App.Config.DefaultDesignId(), false); 
            }
        }
    }

    public class DaoContainer : AbstractDaoDataEntity<Data.Entity.Theme.Container, int>
    {
    }

    public class DaoStyle: AbstractDaoDataEntity<Data.Entity.Theme.Style, int>
    {
        public Data.Entity.Theme.Style Default
        {
            get
            {
                return GetById(App.Config.DefaultStyleId(), false);
            }
        }

    }

    public class DaoBlock : AbstractDaoDataEntity<Data.Entity.Theme.Block, int>
    {
        public List<Data.Entity.Theme.Block> GetByCode(Design parentDesign, string code)
        {
            return GetByCriteria(Expression.Eq("ParentDesign", parentDesign), Expression.Eq("Code", code));
        }
    }

    public partial class Factory
    {
        public static Data.Access.DaoDesign Design
        {
            get { return new Data.Access.DaoDesign(); }
        }

        public static Data.Access.DaoContainer Container
        {
            get { return new Data.Access.DaoContainer(); }
        }

        public static Data.Access.DaoBlock Block
        {
            get { return new Data.Access.DaoBlock(); }
        }

        public static Data.Access.DaoStyle Style
        {
            get { return new Data.Access.DaoStyle(); }
        }       
    }
}